package io.light.frame.dal.mybatis.generator.core.meta.visit.opt;

import io.light.frame.dal.mybatis.generator.core.meta.Dialect;
import io.light.frame.dal.mybatis.generator.core.meta.SupportedDialect;
import io.light.frame.dal.mybatis.generator.core.meta.entity.Table;
import io.light.frame.dal.mybatis.generator.core.meta.entity.TableColumn;

import javax.sql.DataSource;
import java.util.List;

/**
 * Metadata operations
 *
 * @author Ivan
 * @version 1.0.0
 * @date 2021-06-09 13:09
 */
public interface MetaOperations {

    /**
     * Get {@link DataSource} {@link Dialect}
     *
     * @return {@link Dialect}
     * @see SupportedDialect#register(Dialect)
     */
    Dialect getDialect();

    /**
     * Current database name
     *
     * @return database name
     */
    String currentDatabase();

    /**
     * Check database
     *
     * @param database database name
     */
    void checkDatabase(String database);

    /**
     * Get table metadata
     *
     * @param database  database
     * @param tableName table name
     * @return {@link Table}
     */
    Table table(String database, String tableName);

    /**
     * Get table columns metadata
     *
     * @param database  database
     * @param tableName table name
     * @return table columns metadata
     */
    List<TableColumn> columns(String database, String tableName);

    /**
     * Get database tables metadata
     *
     * @param database database
     * @return tables metadata
     */
    List<Table> tableList(String database);
}
